define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'orderjd/index',
                    add_url: 'orderjd/add',
                    edit_url: 'orderjd/edit',
                    del_url: 'orderjd/del',
                    multi_url: 'orderjd/multi',
                    table: 'order_jd',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                searchFormVisible: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'merid', title: __('Merid')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'actualCosPrice', title: __('Actualcosprice'), operate:'BETWEEN'},
                        {field: 'actualFee', title: __('Actualfee'), operate:'BETWEEN'},
                        // {field: 'cid1', title: __('Cid1')},
                        // {field: 'cid2', title: __('Cid2')},
                        // {field: 'cid3', title: __('Cid3')},
                        {field: 'commissionRate', title: __('Commissionrate'), operate:'BETWEEN'},
                        // {field: 'estimateCosPrice', title: __('Estimatecosprice'), operate:'BETWEEN'},
                        {field: 'estimateFee', title: __('Estimatefee'), operate:'BETWEEN'},
                        {field: 'ext1', title: __('Ext1')},
                        {field: 'finalRate', title: __('Finalrate'), operate:'BETWEEN'},
                        // {field: 'frozenSkuNum', title: __('Frozenskunum')},
                        {field: 'payMonth', title: __('Paymonth')},
                        // {field: 'pid', title: __('Pid')},
                        // {field: 'popId', title: __('Popid')},
                        {field: 'positionId', title: __('Positionid')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        // {field: 'siteId', title: __('Siteid')},
                        {field: 'skuId', title: __('Skuid')},
                        {field: 'skuName', title: __('Skuname')},
                        {field: 'skuNum', title: __('Skunum')},
                        // {field: 'skuReturnNum', title: __('Skureturnnum')},
                        {field: 'subSideRate', title: __('Subsiderate'), operate:'BETWEEN'},
                        // {field: 'subUnionId', title: __('Subunionid')},
                        // {field: 'subsidyRate', title: __('Subsidyrate'), operate:'BETWEEN'},
                        // {field: 'traceType', title: __('Tracetype')},
                        // {field: 'unionAlias', title: __('Unionalias')},
                        // {field: 'unionTag', title: __('Uniontag')},
                        // {field: 'unionTrafficGroup', title: __('Uniontrafficgroup')},
                        {field: 'validCode', title: __('Validcode'), visible: false, search: Config.orderStatusList},
                        {field: 'valid_code_text', title: __('Validcode'), operate: false},
                        {field: 'finishTime', title: __('Finishtime')},
                        // {field: 'orderEmt', title: __('Orderemt')},
                        {field: 'orderId', title: __('Orderid')},
                        {field: 'orderTime', title: __('Ordertime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'parentId', title: __('Parentid')},
                        // {field: 'plus', title: __('Plus')},
                        // {field: 'unionId', title: __('Unionid')},
                        {field: 'status', title: __('Status'), visible: false, searchList: Config.statusList},
                        {field: 'status_text', title: __('Status'), operate: false},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});